<template>

    <div class="header-box">

        <div class="l-content">
            <!-- 侧边栏收缩展开按钮 -->
            <el-button @click="handelCollapse()" size="small">
                <el-icon>
                    <Grid />
                </el-icon>
            </el-button>
            <!-- 面包屑 -->
            <el-breadcrumb separator="/" class="bread">
                <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
                <el-breadcrumb-item :to="current.path" v-if="current">{{ current.label }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>


        <div class="r-content">
            <el-dropdown>
                <span class="el-dropdown-link">
                    <img class="user-img" :src="getImgSrc('user')" alt="">
                </span>
                <template #dropdown>
                    <el-dropdown-menu>
                        <el-dropdown-item>Action 1</el-dropdown-item>
                        <el-dropdown-item>Action 2</el-dropdown-item>
                    </el-dropdown-menu>
                </template>
            </el-dropdown>

        </div>
    </div>

</template>

<script setup>
import {computed} from 'vue'
// 引入仓库
import { useAside } from '../store/index.js';
const main = useAside()
// 更新侧边栏展开状态
const handelCollapse = () => {
    main.updateIscollapse()
}

const getImgSrc = (val) => {
    return new URL(`../assets/${val}.png`, import.meta.url).href
}

const current = computed(()=>{
    return main.currentMenu
})


</script>

<style lang="less">
.header-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;

    .l-content {
        display: flex;
        align-items: center;
        .bread {
            margin-left: 10px;
        }
    }
}


.user-img {
    width: 35px;
    height: 35px;
}
</style>